<?php $this -> load -> view('common/head_open'); ?>
<script src="<?php echo SKIN_URL_JS; ?>/jquery-autogrow.js"></script>
<script src="<?php echo SKIN_URL_JS; ?>/jquery.session.js"></script>
<style>
.moreLink {
background-color: transparent;
border: none;
color: #00adee;
cursor: pointer;
padding:0px;
}
</style>
<!--show and hide divs-->
<script>
 var allow = true;
 var check_letter=/^[a-zA-Z0-9]+[a-zA-Z0-9 ]*$/;
$(document).ready(function(){
  /*when member click on class*/
  $(".classes").click(function() {
    $(".member_join_as_form,.member_join_as,.detailed_form,.navigation").hide();
    $(".select_class").show();
	$(".information_inner2 > .go_back").hide();
  });
   /*when member click on back button*/
  $(".go_back").click(function(){
    $(".member_join_as_form,.member_join_as_form2,.member_join_as,.detailed_form,.navigation").show();
	$(".information_inner2 > .go_back").show();
    $(".select_board,.select_class,.select_school,.select_city,.select_state,.select_subject,.select_institute").hide();
  });
  $(".result_not_found").click(function(){
	   item_class=$(this).parent().find('input[type=text]').attr('id');
	   item_text=$(this).parent().find('input[type=text]').val();
	   item_text=item_text.trim();
	   item_class=item_class.split("_").shift();
	   $('.'+item_class).text(item_text);
    $(".member_join_as_form,.member_join_as,.detailed_form,.navigation,.member_join_as_form2").show();
	$(".information_inner2 > .go_back").show();
    $(".select_board,.select_class,.select_school,.select_city,.select_institute,.select_subject,.select_state").hide();
	$(".error").hide();
  });
  
  $(".join_as_detail_class").click(function(){
	 html_item=$(this).html();
	 class_id=$(this).attr('id');
	 class_name=html_item.match(/\d+/)[0];
	 $("#class").val(class_id);
	 $(".classes").text(class_name);
    $(".select_class").hide();
	$(".information_inner2 > .go_back").show();
    $(".member_join_as_form,.member_join_as,.detailed_form,.navigation").show();
  });
  <?php if($member_type == 'teacher' || $member_type == 'educator' || $member_type == 'institute'){ ?>
  /*when member click on subject*/
  $(".subject").click(function()
  {
    $(".member_join_as_form,.member_join_as,.detailed_form,.navigation").hide();
    $(".select_subject").show();
	//$("#subject_id").val($("#subject_1").val());
	$('#subject_id').keydown();
    $("#subject_id").focus();
	$(".information_inner2 > .go_back").hide();
	$(".error").html('');
  });
  /*live school search*/
  $("#subject_id").keyup(function(){
  	$(".error").html('');
	if($(this).val()!='')
	{
		 if(check_letter.test($(this).val())==false)
		 {
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
			$(this).focus();
			return false;
		  }
		 else
		 {
			$(".error").html('');
		 }
	}
	else
	{
		$(".error").html('')
	}
	setTimeout(loadData($(this).val(),'subject'), 5000);
  });
  /*when member click on city*/
  $(".city").click(function()
  {
    $(".member_join_as_form,.member_join_as_form2,.member_join_as,.detailed_form,.navigation").hide();
    $(".select_city").show();
	//$("#city_id").val($("#city_1").val());
	$('#city_id').keydown();
    $("#city_id").focus();
	$(".information_inner2 > .go_back").hide();
	$(".error").html('');
  });
  /*live city search*/
  $("#city_id").keyup(function(){
  	$(".error").html('');
	if($(this).val()!='')
	{
		 if(check_letter.test($(this).val())==false)
		 {
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
			$(this).focus();
			return false;
		  }
		 else
		 {
			$(".error").html('');
		 }
	}
	else
	{
		$(".error").html('')
	}
	setTimeout(loadData($(this).val(),'city'), 5000);
  });
  /*when member state on city*/
  $(".state").click(function()
  {
    $(".member_join_as_form,.member_join_as_form2,.member_join_as,.detailed_form,.navigation").hide();
    $(".select_state").show();
	//$("#state_id").val($("#state_1").val());
	$('#state_id').keydown();
    $("#state_id").focus();
	$(".information_inner2 > .go_back").hide();
	$(".error").html('');
  });
  /*live state search*/
  $("#state_id").keyup(function(){
  	$(".error").html('');
	if($(this).val()!='')
	{
		 if(check_letter.test($(this).val())==false)
		 {
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
			$(this).focus();
			return false;
		  }
		 else
		 {
			$(".error").html('');
		 }
	}
	else
	{
		$(".error").html('')
	}
	setTimeout(loadData($(this).val(),'state'), 5000);
  });
  /*when member click on institute*/
  $(".institute").click(function()
  {
    $(".member_join_as_form2,.member_join_as,.detailed_form,.navigation").hide();
    $(".select_institute").show();
	//$("#institute_id").val($("#institute_1").val());
	$('#institute_id').keydown();
    $("#institute_id").focus();
	$(".information_inner2 > .go_back").hide();
	$(".error").html('');
  });
  /*live school search*/
  $("#institute_id").keyup(function(){
  	$(".error").html('');
	if($(this).val()!='')
	{
		 if(check_letter.test($(this).val())==false)
		 {
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
			$(this).focus();
			return false;
		  }
		 else
		 {
			$(".error").html('');
		 }
	}
	else
	{
		$(".error").html('')
	}
	setTimeout(loadData($(this).val(),'institute'), 5000);
  });
  <?php }?>
  
  /*when member click on school*/
  $(".school").click(function()
  {
    $(".member_join_as_form,.member_join_as,.detailed_form,.navigation").hide();
    $(".select_school").show();
	//$("#school_id").val($("#school_1").val());
    $("#school_id").focus();
	$("#school_id").keydown();
	$(".information_inner2 > .go_back").hide();
	$(".error").html('');
  });
  /*live school search*/
  $("#school_id").keyup(function(){
  	$(".error").html('');
	if($(this).val()!='')
	{
		 if(check_letter.test($(this).val())==false)
		 { 
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
			$(this).focus();
			return false;
		  }
		 else
		 {
			$(".error").html('');
		 }
	}
	else
	{
		$(".error").html('')
	}
	setTimeout(loadData($(this).val(),'school'),5000);
  });
  $("#result_not_found_school").click(function(){
   $("#school_1").val($("#school_id").val());
  $("#school").val($("#school_id").val());
  });
  $("#result_not_found_board").click(function(){
   $("#board_1").val($("#board_id").val());
  $("#board").val($("#board_id").val());
  });
  $("#result_not_found_city").click(function(){
   $("#city_1").val($("#city_id").val());
  $("#city").val($("#city_id").val());
  });
  $("#result_not_found_state").click(function(){
   $("#state_1").val($("#state_id").val());
  $("#state").val($("#state_id").val());
  });
  $("#result_not_found_subject").click(function(){
   $("#subject_1").val($("#subject_id").val());
  $("#subject").val($("#subject_id").val());
  });
  $("#result_not_found_institute").click(function(){
   $("#institute_1").val($("#institute_id").val());
  $("#institute").val($("#institute_id").val());
  });
  
  
  
  /*when member click on board*/
  $(".board").click(function(){
    $(".member_join_as_form,.member_join_as,.detailed_form,.navigation").hide();
    $(".select_board").show();
	//$("#board_id").val($("#board_1").val());
	$('#board_id').keydown();
    $("#board_id").focus();
	$(".information_inner2 > .go_back").hide();
	$(".error").html('');
  });
  /*live board search*/
  $("#board_id").keyup(function(){
	$(".error").html('');
	if($(this).val()!='')
	{
		 if(check_letter.test($(this).val())==false)
		 { 
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
			$(this).focus();
			return false;
		  }
		 else
		 {
			$(".error").html('');
		 }
	}
	else
	{
		$(".error").html('')
	}
	setTimeout(loadData($(this).val(),'board'), 5000);
  });
  //-----------------------//
  <?php if($member_type == 'institute'){?>
  	var email_exp = /\S+@\S+\.\S+/;
	var check_email_letter=/^\s*[a-zA-Z0-9_.@\-\s]+\s*$/;
	email=$("#email");
	phone=$("#phone");
	$(email).change(function(){
		if($(this).val()!='')
		{
		 	if(check_email_letter.test($(this).val())==false||$(this).val().indexOf(" ")>0||email_exp.test($(this).val())==false)
		 	{
				$(".error").html("<?php if(isset($javscript_error['invalid_email'])) echo $javscript_error['invalid_email']  ?>");
				$(this).focus();
				return false;
		 	}
		 	else
		 	{
				$(".error").html('');
			}
		}
		else
		{
			$(".error").html('');
		}
	});
	/*$(email).change(function(){
		$(".error").html('');
		checkEmail($(this).val());
	});*/
	$(email).focusout(function(){
		if($(this).val()=='')	
		{
			$(".error").html("<?php if(isset($javscript_error['email'])) echo $javscript_error['email']  ?>");
	        $(this).focus();
	        return false;
		}
		else if(email_exp.test($(this).val())==false)
		{
			$(".error").html("<?php if(isset($javscript_error['invalid_email'])) echo $javscript_error['invalid_email']  ?>");
			$(this).focus();
			return false;
		}
	});
	if($(email).val() == '')
	{
		$(phone).keyup(function(){
			if($(phone).val()==''||$(phone).val()==null)
			{
				$(".error_box").html('<div class="error"><samp>*</samp>'+"<?php if(isset($javscript_error['phone_number'])) echo $javscript_error['phone_number']  ?>"+'</div>');
				$(phone).focus();
				return false;
			}
			else if(isNaN($(phone).val()) || ($(phone).val().length<10) || ($(phone).val().length>13))
			{
				$(".error_box").html('<div class="error"><samp>*</samp>'+"<?php if(isset($javscript_error['invalid_phone'])) echo $javscript_error['invalid_phone']  ?>"+'</div>');
				$(phone).focus();
				return false;
			}
		});
	}
	
	function checkEmail(q)
	{
		$.ajax({
			url:'<?php echo base_url().BASE ?>'+'check_mail',
            type : 'POST',
            data : {'search' : q},
			success: function (data){
				switch(data) {
                    case ('TRUE'):
                        $('.error').html("<?php echo $this->lang->line('account_creation_duplicate_email');  ?>");
                        $("#email").focus();
						return false;  
                        break;

                    case ('FALSE'):
                        $('.error').html();
                        break;
                }
			}
		});
	}
  <?php }?>
  
  /*when member submit form*/
  $("#detail").click(function(){
  	var type = $("#member_type").val();
  	$("#join_as_form").attr('action', './redirect_'+type);
	$("#join_as_form").submit();
  });
  $("#join_as_member").click(function()
  {
  	<?php if($member_type !='institute'){ ?>
	    first_name=$("#first_name");
		last_name=$("#lastname");
		section=$("#section");
		class_name=$("#class");
		school=$("#school_id");
		board=$("#board_id");
		state=$("#state_id");
		city=$("#city_id");
		subject=$("#subject_id");
		var check_letter=/^[a-zA-Z0-9]+[a-zA-Z0-9 ]*$/;
	
		if(first_name.val().trim()=="" && check_letter.test(first_name.val())==false || first_name.val().indexOf(" ")>0)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['first_name'])) echo $javscript_error['first_name']  ?>");
			first_name.focus();
			return false;
		}
		else if(last_name.val().trim()=="")
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['last_name'])) echo $javscript_error['last_name']  ?>");
			last_name.focus();
			return false;
		}
		else if(class_name.val()==''||class_name.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['class_name'])) echo $javscript_error['class_name']  ?>");
			return false;
		}
		<?php if($member_type == 'student'){ ?>
		else if(section.val()==''||section.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['section'])) echo $javscript_error['section']  ?>");
			section.focus();
			return false;
		}
		<?php }
		if($member_type != 'educator'){?>
		else if(school.val()==''||school.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['school'])) echo $javscript_error['school']  ?>");
			return false;
		}
		<?php }?>
		else if(board.val()==''||board.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['board'])) echo $javscript_error['board']  ?>");
			return false;
		}
		<?php if($member_type == 'teacher' || $member_type == 'educator'){ ?>
		else if(subject.val()==''||subject.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['subject'])) echo $javscript_error['subject']  ?>");
			return false;
		}
		<?php }
		if($member_type == 'educator'){?>
		else if(city.val()==''||city.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['city'])) echo $javscript_error['city']  ?>");
			return false;
		}
		else if(state.val()==''||state.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['state'])) echo $javscript_error['state']  ?>");
			return false;
		}
		<?php }?>
		else if(!$("input:radio[name=gender]").is(":checked"))
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['gender'])) echo $javscript_error['gender']  ?>");
			return false;
		}
		else
		{
			$("#join_as_form").submit();
		}
	<?php  } else{?>
		institute=$("#institute_id");
		state=$("#state_id");
		city=$("#city_id");
		email=$("#email");
		phone=$("#phone");
		if(institute.val()==''||institute.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['insitute_name'])) echo $javscript_error['insitute_name']  ?>");
			return false;
		}
		else if(city.val()==''||city.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['city'])) echo $javscript_error['city']  ?>");
			return false;
		}
		else if(state.val()==''||state.val()==null)
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['state'])) echo $javscript_error['state']  ?>");
			return false;
		}
		else if(email.val()==''||email.val()==null)
		{
			$(".error").html("<?php if(isset($javscript_error['email'])) echo $javscript_error['email']  ?>");
	        email.focus();
	        return false;
		}
		else if(email.val()==''&& phone.val()=='')
		{
			$(".error").html("<?php if(isset($javscript_error['phone_number'])) echo $javscript_error['phone_number']  ?>");
	        phone.focus();
	        return false;
		}
		else if(!$("input:radio[name=category]").is(":checked"))
		{
			$(".error").show();
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['type'])) echo $javscript_error['type']  ?>");
			return false;
		}
		else
		{
			$("#join_as_form").submit();
		}
	<?php }?>
  });
  $(".go_back").click(function(){
  
  $(".error").hide();
  
  });
  
  $("#first_name,#lastname,#section").focusout(function(){
   var check_letter=/^[a-zA-Z0-9]+[a-zA-Z0-9 ]*$/;
	if($(this).val()!='')
	{
		 if(check_letter.test($(this).val())==false || $(this).val().indexOf(" ")>0)
		 { 
			$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
			$(this).focus();
			return false;
		  }
		 else
		 {
			$(".error").html('')
		 }
	}
	else
	{
		$(".error").html('')
	}
  });
  $("#first_name,#lastname,#section").focusout(function(){
  	if($(this).val()== '')
  	{
  		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['required'])) echo $javscript_error['required']  ?>");
		$(this).focus();
		return false;
  	}
  	else
	{
		$(".error").html('')
	}
	if(check_letter.test($(this).val())==false || $(this).val().indexOf(" ")>0)
	{ 
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_input'])) echo $javscript_error['invalid_input']  ?>");
		$(this).focus();
		return false;
	}
	else
	{
		$(".error").html('')
	}
  });
  $(".join_as_detail_class").click(function(){
  	if($("#class").val() == ''){
  		$(".error").show();
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['class_name'])) echo $javscript_error['class_name']  ?>");
		return false;
  	}
  	else
  	{
  		$(".error").html('')
  	}
  });
});
function loadData(q,key_id)
{
	if(allow){
		allow = false;
		$("#"+key_id+"_result").html('loading...');
		$.ajax({
			url:'<?php echo base_url().BASE; ?>'+'live/'+key_id,
            type : 'POST',
            data : {'search' : q},
			success: function (data){
			
			if(data=='No record found. Click on the submit button.')
			   {
				$('.result_not_found').show();
				$('.error').show();
				$("#"+key_id+"_result").html('');
				$(".error").html('No matching record found. Click on the submit to continue.');
			   }
			 else
			   {
				   $('.result_not_found').hide();
					$("#"+key_id+"_result").html(data);
				}
				$("#"+key_id+"_result").find(".join_as_detail_"+key_id).click(function()
				{
					obj_name=$(this).html();
					obj_id=$(this).attr('id');
					$("#"+key_id+"_1").val(obj_name);
					//alert(key_id);
					if(obj_name.length > 14)
					{
						if(key_id=='school'){
						$("."+key_id).text(obj_name.substring(0,25)+"...");
						$("#"+key_id+"_id").val(obj_name);
						}
						else{
						$("."+key_id).text(obj_name.substring(0,14)+"...");
						$("#"+key_id+"_id").val(obj_name);
						}
					}
					else
					{
						$("."+key_id).text(obj_name);
						$("#"+key_id+"_id").val(obj_name);
					}
					//$("."+key_id).text(obj_name);
					$("#"+key_id).val(obj_id);
					$(".select_"+key_id).hide();
					$('#'+key_id+'_other').val('0');
					$(".information_inner2 > .go_back").show();
					$(".member_join_as_form,.member_join_as_form2,.member_join_as,.detailed_form,.navigation").show();
					$(".join_as_detail_"+key_id).hide();
				});
				
				allow = true;
			}
		});
	}}
	//$(".school").click(function(){
	//$("#school_result").hide();
	//$("#comma").hide();
	//})
</script>

<?php $this -> load -> view('common/head_close'); ?>
<!--wrapper starts-->
<section class="wrapper">
	<!--header starts-->
	<?php $this->load->view('common/header'); 
	//var_dump($this->session->userdata('member_data'));die();
	?>
	<!--header closed-->
	<!--Container starts-->
	<div class="container-fluid">
		
		<section class="Container" style="padding-left: 96px; padding-right: 184px;">
			<h1>Zigya <?php echo $h1_title; ?></h1>
			<!--information starts-->
			<div class="col-md-10 col-sm-10 col-lg-10 col-xs-12 zero-padding custom-margin-bottom">
				<!--information starts-->
				<div class="information">
					<!--information_inner starts-->
					<?php
						
						if(isset($member_type) && $member_type!=NULL){
													
							$load_page = 'common/information_inner_join_'.$member_type; 
						}
						$this->load->view($load_page); 
					?>
					<!--information_inner closed-->
					<!--information_nav starts-->
					<?php $this->load->view('common/information_nav'); ?>
					<!--information_nav closed-->
					<div class="clear"></div>
				</div>
			</div>
			<!--information closed-->
			<!--information_aside starts-->
			<?php $this->load->view('common/information_aside'); ?>
			<!--information_aside closed-->
			<div class="clear"></div>
		</section>

	</div>
	<!--Container closed-->
</section>
<!--wrapper closed-->
<?php $this ->load->view('common/footer'); ?>